package com.init.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.init.model.entity.Graders;
import com.init.service.GradersService;
import com.init.mapper.GradersMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 用户 -- 评定人
* @author Atanycosts
* @description 针对表【graders(存储评分人信息)】的数据库操作Service实现
* @createDate 2025-01-04 08:55:18
*/
@Service
public class GradersServiceImpl extends ServiceImpl<GradersMapper, Graders>
    implements GradersService{

    @Resource
    @Lazy
    private GradersService gradersService;
    /**
     * 分页查询
     *
     * @param page
     * @param pageSize
     * @param userAccount
     * @return
     */
    @Override
    public Page queryPage(int page, int pageSize, String userAccount) {
        // 构造分页构造器
        Page pageInfo = new Page(page, pageSize);

        // 构造条件构造器
        LambdaQueryWrapper<Graders> queryWrapper = new LambdaQueryWrapper();

        // 添加过滤条件,模糊查询

        queryWrapper.like(StringUtils.isNotEmpty(userAccount), Graders::getUserAccount, userAccount);

        // 添加排序条件
        queryWrapper.orderByDesc(Graders::getGraderId);

        // 执行查询
        gradersService.page(pageInfo, queryWrapper);
        return pageInfo;
    }
}




